﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO_MechSys;
using System.Data.SqlClient;


namespace DAL_MechSys
{
    public class DALBemVindo : DALBase
    {
        public DTOBemVindo Exibir()
        {
            DTOBemVindo dtoBemVindo = new DTOBemVindo();
            try
            {
                string storedProssidere = "sp_BemVindo";
                ExecuteNonQuery(storedProssidere);
                using (SqlDataReader sqlDataReader = ExecuteReader(storedProssidere))
                {
                    while (sqlDataReader.Read())
                    {
                        if (!string.IsNullOrEmpty(sqlDataReader["ExibirBemVindo"].ToString()))
                        {
                            dtoBemVindo.Exibir = bool.Parse(sqlDataReader["ExibirBemVindo"].ToString());
                        }

                        if (!string.IsNullOrEmpty(sqlDataReader["TempoBemVindo"].ToString()))
                        {
                            dtoBemVindo.Tempo = (int)sqlDataReader["TempoBemVindo"];
                        }
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }
            return dtoBemVindo;
        }

        public void Atualizar(DTOBemVindo dtoBemVindo)
        {
            try
            {
                string storedProssidere = "sp_AtualizarBemVindo";
                SqlParameter[] parameters =

                {                  
                   new SqlParameter("@tempo", dtoBemVindo.Tempo),
                   new SqlParameter("@exibir", dtoBemVindo.Exibir),        
                };
                ExecuteNonQuery(storedProssidere, parameters);
            }
            catch (SqlException)
            {
                throw;
            }
        }
    }
}
